## mako

<%page args="active_page=None" expression_filter="h" />
<%namespace name='static' file='/static_content.html'/>

<%!
from lms.djangoapps.courseware.masquerade import is_masquerading_as_student
from lms.djangoapps.courseware.tabs import get_course_tab_list
from lms.djangoapps.course_goals.models import UserActivity

from django.conf import settings
from django.urls import reverse
from django.utils.translation import gettext as _
%>

<%
if active_page is None and active_page_context is not UNDEFINED:
    # If active_page is not passed in as an argument, it may be in the context as active_page_context
    active_page = active_page_context

if course is not None:
    include_special_exams = (
    request.user.is_authenticated and
    settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and
    (course.enable_proctored_exams or course.enable_timed_exams)
    )

masquerading_as_student = is_masquerading_as_student(request.user, course.id)
%>

% if include_special_exams is not UNDEFINED and include_special_exams:
    <%static:js group='proctoring'/>
    % for template_name in ["proctored-exam-status"]:
        <script type="text/template" id="${template_name}-tpl">
            <%static:include path="courseware/${template_name}.underscore" />
        </script>
    % endfor
    <div class="proctored_exam_status"></div>
% endif

% if disable_tabs is UNDEFINED or not disable_tabs:
    <%
    tab_list = get_course_tab_list(request.user, course)

    # Record course goals user activity for (web) courseware and course tabs that are outside of the learning mfe
    UserActivity.record_user_activity(user, course.id)
    %>
    % if uses_bootstrap:
        <nav class="navbar course-tabs pb-0 navbar-expand" aria-label="${_('Course')}">
            <ul class="navbar-nav mr-auto">
                % for tab in tab_list:
                    <%
                    tab_is_active = tab.tab_id in (active_page, default_tab)
                    %>
                        %  if tab.name == 'Instructor' and masquerading_as_student:
                            <% continue %>
                        % else:
                            <li class="nav-item ${'active' if tab_is_active else ''}">
                                <a href="${tab.link_func(course, reverse)}" class="nav-link">
                                    ${_(tab.name)}
                                    % if tab_is_active:
                                        <span class="sr-only">, ${_('current location')}</span>
                                    %endif
                                    % if tab_image:
                                        ## Translators: 'needs attention' is an alternative string for the
                                        ## notification image that indicates the tab "needs attention".
                                        <img src="${tab_image}" alt="${_('needs attention')}" />
                                    %endif
                                </a>
                            </li>
                        %endif
                % endfor
            </ul>
        </nav>
    % else:
        <nav class="${active_page} wrapper-course-material" aria-label="${_('Course Material')}">
            <div class="course-material">
                <%
                tabs_tmpl = static.get_template_path('/courseware/tabs.html')
                %>
                <ol class="tabs course-tabs">
                    <%include file="${tabs_tmpl}" args="tab_list=tab_list,active_page=active_page,default_tab=default_tab,tab_image=tab_image" />
                    <%block name="extratabs" />
                </ol>
            </div>
        </nav>
    % endif
%endif
